<?php



namespace App\Http\Requests\Company;


use Illuminate\Support\Facades\Auth;


class VideoMakerRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $rules = [
            'items.*.title' => 'required|max:255',
            'items.*.start_point' => 'required',
        ];
        return $rules;
    }

    public function messages()
    {
        return [
            'items.*.title.required' => __('每个项的输入都需要一个标题'),
            'items.*.title.max' => __('每个标记标题长度不能超过:size个字符', ['size' => 255]),
            'items.*.start_point.required' => __('每个项的输入都需要一个起始点'),
        ];
    }

    public function filldata()
    {
        $items = $this->input('items', []);

        $data = [];
        foreach ($items as $item) {
            $data[] = [
                'title' => (string)$item['title'],
                'start_point' => (int)$item['start_point'],
            ];
        }

        return $data;
    }
}
